<?php

namespace app\api\controller\xykeep;
use app\common\controller\Api;
use app\api\model\xykeep\user\Course as UserCourseModel;
use app\api\model\xykeep\CourseTimesec as CourseTimesecModel;

/**
 * XYkeep用户课程接口
 */
class UserCourse extends Api
{
    protected $noNeedLogin = [];
    protected $noNeedRight = ['*'];
    
	/**
	 * 课程列表
	 */
	public function lists()
    {
        $params = $this->request->post();
        $data = UserCourseModel::getUserCourseList($params);
        $this->success('用户课程列表', $data);
    }

    /**
     * 常约课程和教练
     */
    public function usual_course()
    {
        $params = $this->request->post();
        $data = UserCourseModel::getUsual($params);
        $this->success('常约课程', $data);
    }

    /**
     * 快捷约课
     */
    public function fast_course()
    {
        $data = [];
        $data['fast_course'] = CourseTimesecModel::with(['course'])->group('course_id')->order('id desc')->limit(0,10)->select();
        foreach ($data['fast_course'] as $key => &$value) {
            $value = $value['course'];
            $value['course_id'] = $value['id'];
        }
        $data['fast_coach'] = CourseTimesecModel::with(['coach'])->group('coach_id')->order('id desc')->limit(0,10)->select();

        $this->success('快捷约课', $data);
    }

}